home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form frmMain
- Caption = "Crescent Internet ToolPak - Receive File"
- ClientHeight = 6090
- ClientLeft = 1335
- ClientTop = 990
- ClientWidth = 6600
- Height = 6495
- Left = 1275
- LinkTopic = "Form1"
- ScaleHeight = 6090
- ScaleWidth = 6600
- Top = 645
- Width = 6720
- Begin VB.ListBox Files
- BackColor = &H00C0C0C0&
- BeginProperty Font
- name = "Courier New"
- charset = 0
- weight = 400
- size = 9
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H00800000&
- Height = 1830
- Left = 3360
- TabIndex = 4
- Top = 960
- Width = 3135
- End
- Begin VB.ListBox Directories
- BackColor = &H00C0C0C0&
- BeginProperty Font
- name = "Courier New"
- charset = 0
- weight = 400
- size = 9
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H00800000&
- Height = 1830
- Left = 120
- TabIndex = 3
- Top = 960
- Width = 3015
- End
- Begin VB.CommandButton cmdLogin
- Caption = "LOGIN to ftp.progress.com"
- Height = 375
- Left = 120
- TabIndex = 2
- Top = 120
- Width = 3015
- End
- Begin VB.CommandButton cmdQuit
- Caption = "QUIT"
- Height = 375
- Left = 5040
- TabIndex = 1
- Top = 5640
- Width = 1455
- End
- Begin VB.TextBox txtOutput
- Height = 2415
- Left = 120
- Locked = -1 'True
- MultiLine = -1 'True
- ScrollBars = 2 'Vertical
- TabIndex = 0
- Top = 3120
- Width = 6375
- End
- Begin VB.Label lblFiles
- Caption = "Files:"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 210
- Left = 3345
- TabIndex = 6
- Top = 690
- Width = 3015
- End
- Begin VB.Label lblDirectories
- Caption = "Directories:"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 225
- Left = 120
- TabIndex = 5
- Top = 690
- Width = 3015
- End
- Begin CIFTPLib.CIFTP CIFTP1
- Height = 450
- Left = 3465
- Top = 105
- Width = 480
- _Version = 65537
- _ExtentX = 847
- _ExtentY = 794
- _StockProps = 0
- AccessChannelConnectionWAV= ""
- AccessChannelClosedWAV= ""
- DataChannelConnectionWAV= ""
- DataChannelClosedWAV= ""
- FileClosedWAV = ""
- ListBoxesPopulatedWAV= ""
- SocketClosedWAV = ""
- WSAErrorWAV = ""
- HostName = "ftp.progress.com"
- HostAddress = ""
- RemoteFileName = ""
- LoginName = "anonymous"
- Password = "stephenc@progress.com"
- RepresentationType= ""
- WorkingDirectory= "/"
- End
- Attribute VB_Name = "frmMain"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- ' flag which indicates when TRUE
- ' we want to see a directory listing
- Dim bDirList As Boolean
- Sub OutputText(sText As String)
- On Error Resume Next
- txtOutput.Text = txtOutput.Text & sText
- If Err = 7 Then
- 'Out of memory. Remove some data from the beginning of the text
- 'box to make room for the new data.
- On Error GoTo 0
- txtOutput.Text = Mid$(txtOutput.Text, Len(sText) + 1) & sText
- End If
- txtOutput.SelStart = Len(txtOutput.Text)
- End Sub
- Private Sub CIFTP1_AccessControlChannelClosed()
- ' the access control channel has been closed
- OutputText "AccessControlChannelClosed" + vbCrLf
- End Sub
- Private Sub CIFTP1_AccessControlChannelConnection()
- ' the access control channel connection has been established
- OutputText "AccessControlChannelConnection" + vbCrLf
- ' Once we have established an access channel we
- ' can login to the FTP server and get a data port
- ' so we can establish a data channel connection
- CIFTP1.USER ' send the user name -- found in the LoginName property
- CIFTP1.PASS ' send the password -- found in the Password property
- CIFTP1.PWD ' update the WorkingDirectory property
- CIFTP1.PASV ' call pasv -- this requests a data port from the ftp server.
- ' If successfull the DataPort property is set and the DataPortSet event fires
- End Sub
- Private Sub CIFTP1_AccessControlPacketReceived(ByVal Packet As String)
- ' packet received on the access control channel
- OutputText Packet
- End Sub
- Private Sub CIFTP1_DataControlChannelClosed()
- ' the FTP server has closed the data control channel
- OutputText "DataControlChannelClosed" + vbCrLf
- End Sub
- Private Sub CIFTP1_DataControlChannelConnection()
- ' we have connected to the data channel
- ' we can now invoke ftp methods that move data across
- ' the data channel (LIST, RETR, STOR, etc.)
- OutputText "DataControlChannelConnection" + vbCrLf
- ' if the directories flag is set, then request a dir listing via LIST method...
- If bDirList = True Then
- ' clear the listboxes so we can fill them
- Directories.Clear
- Files.Clear
-
- ' change the form caption to the FTP server working directory
- frmMain.Caption = CIFTP1.WorkingDirectory
- ' issue the file/directory list request
- ' this updates both the list boxes and the files collection
- CIFTP1.List
- Else ' otherwise retrieve a file...
- CIFTP1.RETR ' Note, you must set the LocalFileName and RemoteFileName properties before invoking this method
- End If
- End Sub
- Private Sub CIFTP1_DataPortSet()
- ' the data port has been assigned by the FTP server
- OutputText "DataPortSet" + vbCrLf
- OutputText LTrim$(Str$(CIFTP1.DataPort)) + vbCrLf
- ' wait...
- Screen.MousePointer = 11
- ' we must find update the ServerOSType by
- ' calling CITCP1.SYST
- 'CIFTP1.SYST 'Obsolete as of version 3
- ' now that we have a data port assigned, we can
- ' request a data channel connection
- CIFTP1.ConnectToDataChannel
- End Sub
- Private Sub CIFTP1_FileClosed()
- ' we're ready for the next request
- Screen.MousePointer = 0
- If bDirList = False Then
- MsgBox ("GET File Completed")
- End If
- ' the incoming stream has been closed
- OutputText "FileClosed" + vbCrLf
- ' we expect ASCII data
- CIFTP1.RepresentationType = "A"
- CIFTP1.TYPE
- ' we expect a directory listing
- bDirList = True
- ' make sure we set the local file name
- ' even for directory listings
- CIFTP1.LocalFileName = "C:\$$$DIR.DAT"
- End Sub
- Private Sub CIFTP1_SocketClosed()
- ' the socket has been closed
- OutputText "SocketClosed" + vbCrLf
- End Sub
- Private Sub CIFTP1_WSAError(ByVal error_number As Integer)
- ' If this event fires, then an error has occured, so output an error message
- Dim ErrString As String
- Dim ErrConstDescription As String
- Dim ErrDescription As String
- ErrDescription = WSAErrDescription(error_number, ErrConstDescription)
- ErrString = "WinSock error " & Format$(error_number, "") & ", " & ErrConstDescription & ": " & ErrDescription & vbCrLf
- OutputText ErrString
- End Sub
- Private Sub cmdQuit_Click()
- ' break the FTP server connect and
- ' enable the login button
- CIFTP1.QUIT
- cmdLogin.Enabled = True
- End
- End Sub
- Private Sub cmdLogin_Click()
- ' make form caption = HostName
- frmMain.Caption = CIFTP1.HostName
- ' we are in the process of connecting
- cmdLogin.Enabled = False
- ' set the listboxes to be filled
- Set CIFTP1.DirectoryListBoxName = Directories
- Set CIFTP1.FileListBoxName = Files
- ' connect to access control channel
- CIFTP1.ConnectToAccessControlChannel
- End Sub
- Private Sub Directories_DblClick()
- ' a directory selection has been made
- ' now update the listboxes
- If Screen.MousePointer = 0 Then
- If Directories.List(Directories.ListIndex) = ".." Then
- CIFTP1.WorkingDirectory = ".."
- CIFTP1.CWD
- ElseIf Directories.List(Directories.ListIndex) = "." Then
- ' don't do anything
- Else
- CIFTP1.WorkingDirectory = Directories.List(Directories.ListIndex)
- CIFTP1.CWD
- End If
- CIFTP1.PWD
- CIFTP1.PASV ' call pasv -- this requests a data port from the ftp server.
- ' If successfull the DataPort property is set and the DataPortSet event fires
- End If
- End Sub
- Private Sub Form_Load()
- '-----------------------------------------------------------------------
- ' SUBJECT: ListFile.VBP
- ' AUTHOR: Stephen R. Casella
- ' Progress Software Corporation
- ' Crescent Division
- ' REVISED: March 12, 1996 - sc
- ' DESCRIPTION: Lists files found on the Progress Software Corporation
- ' FTP server for a specified directory.
- '------------------------------------------------------------------------
- ' center main form on the screen
- Me.Top = (Screen.Height - Me.Height) \ 2
- Me.Left = (Screen.Width - Me.Width) \ 2
- ' we want to see a directory listing, so set flag
- bDirList = True
- End Sub
-